package com.spring.mvc.service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.spring.mvc.bean.T0003maesDire;
import com.spring.mvc.bean.UbigeoBean;
import com.spring.mvc.dao.T0003maesDireMapper;

@Service
public class DireccionServiceImpl implements DireccionService{
	@Autowired
	private T0003maesDireMapper t0003maesDireMapper ;
	@Override
	public List<T0003maesDire> selectAllDireccion(String ubigeo ,String direcion)
			throws Exception {
		Map<String, Object> mapparan=new HashMap<String, Object>();
		mapparan.put("COD_UBIG", ubigeo);		
		if(direcion !=null){
			mapparan.put("DIRECLIKE",'%'+direcion+'%');
		}else{
			mapparan.put("DIRECLIKE",direcion);
		}
		List<T0003maesDire> listaDireccion=t0003maesDireMapper.selectDireccionByUbigeo(mapparan);
		return listaDireccion;
	}
	@Override
	public UbigeoBean selectUbigeo(String ubigeo) {
		Map<String, Object> mapparan=new HashMap<String, Object>();
		mapparan.put("UBIGEO", ubigeo.trim());
//		mapparan.put("COD_PROV", dist.getCodProv());
//		mapparan.put("COD_DIST", dist.getCodDist());
		List<UbigeoBean> listaDireccion=null;
		try {
			listaDireccion=t0003maesDireMapper.selectUbigeo(mapparan);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
		return (listaDireccion!=null && listaDireccion.size()>0)?listaDireccion.get(0):null;
	}

	
	
	

}
